var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (i, t) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, i) {
              e.__proto__ = i;
            }) ||
          function (e, i) {
            for (var t in i)
              Object.prototype.hasOwnProperty.call(i, t) && (e[t] = i[t]);
          })(i, t);
      };
      return function (i, t) {
        function a() {
          this.constructor = i;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        e(i, t),
          (i.prototype =
            null === t
              ? Object.create(t)
              : ((a.prototype = t.prototype), new a()));
      };
    })(),
  EmailMainControllerView = (function (e) {
    function i() {
      var i = e.call(this) || this;
      return (
        (i.mainArray = []),
        (i.tempArray = []),
        (i.onLoadEmailViewData = {
          caller: i,
          code: 1171,
          method: function (e) {
            var t = e.list;
            (i.tempArray = e.list), (i.list_receiver_main.visible = !0);
            var a;
            i.mainArray = [];
            for (var n = 0; n < t.length; n++)
              (a = {
                mainEmailLabel: { text: t[n].name },
                timeEmailLabel: { text: i.getDateDiff(t[n].createTime) },
                chakan_email_button: { label: "查看" },
              }),
                i.mainArray.push(a);
            i.list_receiver_main.dataSource = i.mainArray;
          },
        }),
        i.btn_email_cancle.on(Laya.Event.CLICK, i, i.onEmailCancleFn),
        i.btn_send_email_fun.on(Laya.Event.CLICK, i, i.onSendEmailDidClickFn),
        i.tab_mainEmail.on(Laya.Event.CLICK, i, i.onTabMainEmailDidClick),
        WebSocketService.addListener(i.onLoadEmailViewData),
        (i.list_receiver_main.vScrollBarSkin = ""),
        (i.list_receiver_main.selectEnable = !0),
        i.list_receiver_main.on(Laya.Event.CLICK, i, i.onEmailDidClickFn),
        i
      );
    }
    return (
      __extends(i, e),
      (i.openEmailView = function () {
        return (
          null == this.emailVC && (this.emailVC = new i()),
          (this.emailVC.tab_mainEmail.selectedIndex = 0),
          (this.emailVC.list_receiver_main.visible = !1),
          WebSocketService.send({ c: 1171, d: { type: "1", pageNum: 0 } }),
          Laya.stage.addChild(this.emailVC),
          this.emailVC
        );
      }),
      (i.prototype.onTabMainEmailDidClick = function (e) {
        (this.list_receiver_main.visible = !1),
          "item0" == e.target.name
            ? WebSocketService.send({ c: 1171, d: { type: "1", pageNum: 0 } })
            : "item1" == e.target.name &&
              WebSocketService.send({ c: 1171, d: { type: "2", pageNum: 0 } });
      }),
      (i.prototype.onSendEmailDidClickFn = function () {
        0 == this.tab_mainEmail.selectedIndex
          ? SendEmailEditView.openSendEmailView("", "receiver_email_type")
          : SendEmailEditView.openSendEmailView("", "send_email_type");
      }),
      (i.prototype.onEmailDidClickFn = function (e) {
        if ("" != e.target.name) {
          var i = this.tempArray[this.list_receiver_main.selectedIndex].id;
          0 == this.tab_mainEmail.selectedIndex
            ? EmailDetailDialog.showEmailDetail(i, "receiver_email_type")
            : 1 == this.tab_mainEmail.selectedIndex &&
              EmailDetailDialog.showEmailDetail(i, "send_email_type");
        }
      }),
      (i.prototype.getDateDiff = function (e) {
        var i = new Date(),
          t = (i.getFullYear(), i.getMonth() + 1),
          a = i.getDate(),
          n = i.getHours(),
          r = i.getMinutes(),
          l = e.substring(0, 4),
          o = e.substring(5, 7),
          s = e.substring(8, 10),
          m = parseInt(e.substring(11, 13)),
          c = e.substring(14, 16),
          _ = e.substring(17, 19),
          d = (Math.abs(t - o), Math.abs(a - s)),
          u = Math.abs(n - m),
          p = Math.abs(r - c);
        return d > 365
          ? l + "-" + o + "-" + s + "\n" + m + ":" + c + ":" + _
          : d > 1
          ? d + "天前"
          : 0 == d && u > 0 && u <= 24
          ? u + "小时前"
          : 1 == d
          ? u > 0 && u <= 24
            ? n + (24 - m) + "小时前"
            : l + "-" + o + "-" + s + "\n" + m + ":" + c + ":" + _
          : p > 0 && p <= 60
          ? p + "分钟前"
          : "1分钟前";
      }),
      (i.prototype.onEmailCancleFn = function () {
        this.removeSelf();
      }),
      i
    );
  })(ui.EmailController.EmailMainControllerViewUI);
